{extend name="platform/base" /}
{block name="resources"/}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/defau.css">
<script src="ADMIN_JS/art_dialog.source.js"></script>
<script src="ADMIN_JS/iframe_tools.source.js"></script>
<script src="ADMIN_JS/material_managedialog.js"></script>
{/block}
{block name="main"}
<input type="hidden" id="withdraw_id" value="{$list['id']}">

<section class="panel panel-default">
	<header class="panel-heading font-bold"> 提现设置 </header>
	<div class="panel-body">
		<form class="form-horizontal">
			<div class="form-group">
				<label class="col-sm-2 control-label">最低提现金额:</label>
				<div class="col-md-3">
					<input id="cash_min" type="number" min="0.00"  value="{$list['value']['withdraw_cash_min']}" class="form-control"/><span class="withdraw_rule" id="verification_cash">提现金额不能为空</span>
					<br/><a class="hint" style="color:#BBB;">提现金额将不小于此值才能提现,单位/元</a>
				</div>
			</div>
			<div class="line line-dashed line-lg pull-in"></div>
	        <div class="form-group">
				<label class="col-sm-2 control-label">提现倍数:</label>
				<div class="col-md-3">
					<input id="multiple" type="number" min="0.00"  value="{$list['value']['withdraw_multiple']}" class="form-control"/><span class="withdraw_rule" id="verification_multiple">提现倍数不能为空</span>
				    <br/><a class="hint" style="color:#BBB;">提现倍数为必须大于0的整数</a>
				</div>
			</div>
	<!-- 		<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-2 control-label">提现手续费比例:</label>
				<div class="col-md-4">
					<input id="poundage" type="number" min="0.00" step="0.01"  value="{$list['value']['withdraw_poundage']}" class="form-control"/>&nbsp;%<span class="withdraw_rule" id="verification_poundage">提现手续费不能为空</span>
				    <br/><a class="hint" style="color:#BBB;">为0表示不收手续费</a>
				</div>
			</div> -->
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-2 control-label">提现提示信息:</label>
				<div class="col-md-3">
					<textarea name="store_zy" rows="2" id="message" class="form-control" style="height:150px;" maxlength="50">{$list['value']['withdraw_message']}</textarea><span class="withdraw_rule" id="verification_message">提现提示信息不能为空</span>
				</div>
			</div>
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<label class="col-sm-2 control-label">是否启用:</label>
				<div class="col-md-4">
					<label class="radio inline" style="margin-bottom:10px;"><input type="radio" name="enable" value="1"  id="enableYes">启用</label> 
					<label class="radio inline" style="margin-bottom:10px;"><input type="radio" name="enable" value="0"  id="enableNo">禁用</label>
					<input type="hidden" id="is_open" value="{$list['is_use']}">
					<br/><a class="hint" style="color:#BBB;">是否启用提现设置</a>
				</div>
			</div>
			
			<div class="line line-dashed line-lg pull-in"></div>
			<div class="form-group">
				<div class="col-sm-4 col-sm-offset-2">
					<a href="javascript:void(0);" onclick="setMemberwithdrawAjax()" class="btn btn-primary">提交</a>
				</div>
			</div>
			
		</form>
	</div>
</section>

<script src="ADMIN_JS/ajax_file_upload.js" type="text/javascript"></script>
<script src="__STATIC__/js/file_upload.js" type="text/javascript"></script>
<script>

var validation = true;//验证余额输入
/* $("#poundage").live("keyup",function(){
	var reg = /^\d+(.{0,1})(\d{0,2})$/;
	if(!reg.test($(this).val())){
		showTip("请输入大于0的数字，并且保留两位小数","warning");
		validation = false;
	}else{
		validation = true;
	}
}) */
	function setMemberwithdrawAjax() {
		var is_use = $("input[type='radio'][name='enable']:checked").val();
		var cash_min = $("#cash_min").val();
		var multiple = $("#multiple").val();
		// var poundage = $("#poundage").val();
		var poundage = 0;
		var message = $("#message").val();
		if(!(cash_min>0)){
			$("#cash_min").focus();
			showMessage('error',"最低提现金额必须大于0");
			return false;
		}
		
		if(!(/^\+?[1-9]\d*$/).test(multiple)){
			$("#multiple").focus();
			showMessage('error',"提现倍数必须大于0的整数");
			return false;
		}
		if(validation){
			$.ajax({
				type : "post",
				url : "{:__URL('PLATFORM_MAIN/config/memberwithdrawsetting')}",
				data : {
					'cash_min' : cash_min,
					'multiple' : multiple,
					'poundage' : poundage,
					'message' : message,
					'is_use' : is_use
				},
				success : function(data) {
					//alert(JSON.stringify(data));
					if (data['code'] > 0) {
						showMessage('success',"提交成功");
					} else {
						showMessage('error',"提交失败");
					}
				}
			});
		}else{
			showMessage("请输入大于0的数字，并且保留两位小数","warning");
		}
	}
	window.onload=function(){
		var is_open = $("#is_open").val();
		if(is_open == ''){
			is_open = 0;
		}
		if(parseInt(is_open) == 0){
			$("#enableNo").prop("checked","checked");
		}else{
			$("#enableYes").prop("checked","checked");
		}
	}
</script>
{/block}